package model

import "strings"

type Log struct {
	Id           uint   `json:"id" gorm:"id"`
	UserId       uint   `json:"user_id" gorm:"user_id"`
	Path         string `json:"path" gorm:"path"`
	Method       string `json:"method" gorm:"method"`
	Ip           string `json:"ip" gorm:"ip"`
	Agent        string `json:"agent" gorm:"agent"`
	Body         string `json:"body" gorm:"body"`
	Status       uint   `json:"status" gorm:"status"`
	ResponseData string `json:"response_data" gorm:"response_data"`
	ApiName      string `json:"api_name" gorm:"api_name"`
	Role         string `json:"role" gorm:"role"`
	CreateTime   int64  `json:"create_time" gorm:"create_time"`
	User         User   `json:"user" gorm:"foreignkey:UserId"`
}

func GetRoleZhName(role string) string {
	if strings.Contains(role, "super-admin") {
		return "管理员"
	}
	if strings.Contains(role, "operator") {
		return "操作员"
	}
	if strings.Contains(role, "logger") {
		return "审计员"
	}
	if strings.Contains(role, "admin") {
		return "管理员"
	}
	return ""
}
